from state.block import WorldBlock


class Resource:
    def __init__(self, storage=0, daily=0):
        self.storage = storage
        self.daily = daily

    def next(self):
        self.storage += self.daily


class ResPanel:
    def __init__(self):
        self.energy = Resource(0, 10)
        self.mineral = Resource(0, 10)
        self.food = Resource(0, 10)
        self.customer = Resource(0, 5)
        self.alloy = Resource(0, 10)

    def update_for_block(self, block: WorldBlock, neg=1):
        for res_name, res_product in block.produce.items():
            r: Resource = getattr(self, res_name)
            r.daily += neg * res_product
